<?php
namespace common\models\shop;

use common\models\Common;
use yii\db\ActiveRecord;


class GoodsCategory extends Common
{
    public static function tableName()
    {
        return '{{%goods_category}}';
    }

    //category 与 goods关联表
    public function getCategoryGoodsRelation() {
        return $this->hasMany(GoodsCategoryRelation::className(), ['category_id' => 'id']);
    }

    //获取goods 对应的 category
    public function getGoods() {
        return $this->hasMany(Goods::className(), ['id' => 'goods_id'])
            ->via('categoryGoodsRelation');
    }

}